package cn.lanqiao.springboot.entity;

import cn.lanqiao.springboot.groupinterface.PhoneLogin;
import cn.lanqiao.springboot.groupinterface.UserLogin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    private int userId;
    @NotNull(message = "用户名不能为空" ,groups = UserLogin.class)
    @Pattern(regexp = "^\\w{2,10}$",message = "用户名格式错误！" ,groups = UserLogin.class)
    private String userName;
    @NotNull(message = "密码不能为空")
    private String password;
    private String email;
    private Integer isLocked;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @NotNull(message = "手机号不能为空" ,groups = PhoneLogin.class)
    @Pattern(regexp = "^1[3-9][0-9]{9}$", message = "手机号格式错误" ,groups = PhoneLogin.class)
    private String phone;
}
